package com.hz.monitoring.module.hardware.socket.ifwl_gprs_v2.handler;

import com.hz.monitoring.module.hardware.socket.util.BinHexOctUtil;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * 编码
 */
public class EncoderHandler extends MessageToByteEncoder<String> {
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, String hexString, ByteBuf byteBuf) throws Exception {
        //将16进制字符串转为数组
        String s = hexString.replace("FD", "FDED").replace("FE", "FDEE");
        byteBuf.writeBytes(BinHexOctUtil.hexStringToBytes(s));
    }

}